<!DOCTYPE html>



  


<html class="theme-next muse use-motion" lang>
<head><meta name="generator" content="Hexo 3.9.0">
  <meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform">
<meta http-equiv="Cache-Control" content="no-siteapp">
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css">







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css">

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Hexo, NexT">










<meta name="description" content="WEB程序执行流程 客户端（浏览器）发出HTTP请求，到达服务器端，服务器程序接收解析请求报文，发送给框架程序（Django）。框架程序接受到HTTP请求对象（request）后进行中间层处理，然后生成HTTP相应对象（response），再传回给服务器程序构造返回HTTP响应报文。响应给前端客户端。 MVC设计模式  M全拼为Model，主要封装对数据库层的访问，对数据库中的数据进行增、删、改、">
<meta name="keywords" content="STM32,c++,Java,电子设计,Linux">
<meta property="og:type" content="article">
<meta property="og:title" content="Django基础">
<meta property="og:url" content="https://hxk0912.github.io/2021/03/05/Django基础/index.html">
<meta property="og:site_name" content="侯学凯的博客">
<meta property="og:description" content="WEB程序执行流程 客户端（浏览器）发出HTTP请求，到达服务器端，服务器程序接收解析请求报文，发送给框架程序（Django）。框架程序接受到HTTP请求对象（request）后进行中间层处理，然后生成HTTP相应对象（response），再传回给服务器程序构造返回HTTP响应报文。响应给前端客户端。 MVC设计模式  M全拼为Model，主要封装对数据库层的访问，对数据库中的数据进行增、删、改、">
<meta property="og:locale" content="default">
<meta property="og:image" content="https://hxk0912.github.io/博客图片/web_processing_sequence.png">
<meta property="og:image" content="https://hxk0912.github.io/博客图片/mvc.png">
<meta property="og:image" content="https://hxk0912.github.io/博客图片/mvt.png">
<meta property="og:updated_time" content="2021-03-19T08:58:37.236Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Django基础">
<meta name="twitter:description" content="WEB程序执行流程 客户端（浏览器）发出HTTP请求，到达服务器端，服务器程序接收解析请求报文，发送给框架程序（Django）。框架程序接受到HTTP请求对象（request）后进行中间层处理，然后生成HTTP相应对象（response），再传回给服务器程序构造返回HTTP响应报文。响应给前端客户端。 MVC设计模式  M全拼为Model，主要封装对数据库层的访问，对数据库中的数据进行增、删、改、">
<meta name="twitter:image" content="https://hxk0912.github.io/博客图片/web_processing_sequence.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: 'Author'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://hxk0912.github.io/2021/03/05/Django基础/">





  <title>Django基础 | 侯学凯的博客</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="default">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">侯学凯的博客</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">一个大学生的技术博客</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br>
            
            Home
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br>
            
            Archives
          </a>
        </li>
      

      
    </ul>
  

  
</nav>

<script>
    
    window.onload = function(){
        var path = 'https://hxk0912.github.io'; //这里要改成你博客的地址
        var localhostItem = String(window.location).split(path)[1];
        var LiNode = document.querySelectorAll('#menu > li > a')
        
        for(var i = 0; i< LiNode.length;i++){
            var item = String(LiNode[i].href).split(path)[1];
            if(item == localhostItem && item != undefined){
                LiNode[i].setAttribute('style','border-bottom:1px solid black');
            }
        }
    };

</script>


 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://hxk0912.github.io/2021/03/05/Django基础/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Kai">
      <meta itemprop="description" content>
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="侯学凯的博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Django基础</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">Posted on</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2021-03-05T11:05:36+08:00">
                2021-03-05
              </time>
            

            

            
          </span>

          
            <span class="post-category">
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">In</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Django/" itemprop="url" rel="index">
                    <span itemprop="name">Django</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="WEB程序执行流程"><a href="#WEB程序执行流程" class="headerlink" title="WEB程序执行流程"></a>WEB程序执行流程</h2><p><img src="\博客图片/web_processing_sequence.png" alt></p>
<p>客户端（浏览器）发出HTTP请求，到达服务器端，服务器程序接收解析请求报文，发送给框架程序（Django）。框架程序接受到HTTP请求对象（request）后进行中间层处理，然后生成HTTP相应对象（response），再传回给服务器程序构造返回HTTP响应报文。响应给前端客户端。</p>
<h2 id="MVC设计模式"><a href="#MVC设计模式" class="headerlink" title="MVC设计模式"></a>MVC设计模式</h2><p><img src="\博客图片/mvc.png" alt></p>
<ul>
<li>M全拼为Model，主要封装对数据库层的访问，对数据库中的数据进行增、删、改、查操作。</li>
<li>V全拼为View，用于封装结果，生成页面展示的html内容。</li>
<li>C全拼为Controller，用于接收请求，处理业务逻辑，与Model和View交互，返回结果。</li>
</ul>
<h2 id="MVT设计模式"><a href="#MVT设计模式" class="headerlink" title="MVT设计模式"></a>MVT设计模式</h2><p><img src="\博客图片/mvt.png" alt></p>
<ul>
<li>M全拼为Model，与MVC中的M功能相同，负责和数据库交互，进行数据处理。</li>
<li>V全拼为View，与MVC中的C功能相同，接收请求，进行业务处理，返回应答。</li>
<li>T全拼为Template，与MVC中的V功能相同，负责封装构造要返回的html。</li>
</ul>
<h2 id="创建工程"><a href="#创建工程" class="headerlink" title="创建工程"></a>创建工程</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">django-admin startproject demo</span><br></pre></td></tr></table></figure>
<p>运行开发服务器</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">python manage.py runserver</span><br></pre></td></tr></table></figure>
<p>默认IP 127.0.0.1 默认端口8000</p>
<h2 id="创建子应用"><a href="#创建子应用" class="headerlink" title="创建子应用"></a>创建子应用</h2><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">python manage.py startapp 子应用名称</span><br></pre></td></tr></table></figure>
<p>注册安装子应用</p>
<p>子应用不能直接使用，需要进行注册安装后才可以。</p>
<p><strong>注册安装一个子应用的方法，即是将子应用的配置信息文件apps.py中的Config类添加到INSTALLED_APPS列表中。</strong></p>
<p>例如，将刚创建的users子应用添加到工程中，可在INSTALLED_APPS列表中添加’users.apps.UsersConfig’。</p>
<h2 id="创建视图"><a href="#创建视图" class="headerlink" title="创建视图"></a>创建视图</h2><p>Django用视图来编写Web应用的业务逻辑。</p>
<p>在users里的view.py里添加</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> django.http <span class="keyword">import</span> HttpResponse</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">index</span><span class="params">(requset)</span>:</span></span><br><span class="line">    <span class="keyword">return</span> HttpResponse(<span class="string">'Hello,World!'</span>)</span><br></pre></td></tr></table></figure>
<ul>
<li>视图函数的第一个传入参数必须定义，用于接收Django构造的包含了请求数据的HttpReqeust对象，通常名为request。</li>
<li>视图函数的返回值必须为一个响应对象，不能像Flask一样直接返回一个字符串，可以将要返回的字符串数据放到一个HTTPResponse对象中。</li>
</ul>
<p>在子应用目录下新建urls.py用于定义当前子应用下的所有路由</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="keyword">from</span> django.urls <span class="keyword">import</span> path</span><br><span class="line"><span class="keyword">from</span> . <span class="keyword">import</span> views</span><br><span class="line">urlpatterns=[</span><br><span class="line">    path(<span class="string">'index/'</span>,views.index)</span><br><span class="line">]</span><br></pre></td></tr></table></figure>
<p>在总路由中添加子路由的路由数据</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="keyword">from</span> django.contrib <span class="keyword">import</span> admin</span><br><span class="line"><span class="keyword">from</span> django.urls <span class="keyword">import</span> path</span><br><span class="line"><span class="keyword">from</span> django.urls <span class="keyword">import</span> include</span><br><span class="line"></span><br><span class="line">urlpatterns = [</span><br><span class="line">    path(<span class="string">'admin/'</span>, admin.site.urls),</span><br><span class="line">    path(<span class="string">'users/'</span>,include(<span class="string">'users.urls'</span>)),</span><br><span class="line">]</span><br></pre></td></tr></table></figure>
<p><strong>注意：定义子路由时尽量在最后添加‘/’，因为浏览器可以进行重定向自行添加‘/’，但是不可以自行删除‘/’</strong></p>
<h2 id="访问静态文件"><a href="#访问静态文件" class="headerlink" title="访问静态文件"></a>访问静态文件</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">STATIC_URL = <span class="string">'/static/'</span></span><br><span class="line"></span><br><span class="line">STATICFILES_DIRS = [</span><br><span class="line">    BASE_DIR / <span class="string">"static"</span>,</span><br><span class="line">    <span class="string">'/static_files/'</span>,</span><br><span class="line">]</span><br></pre></td></tr></table></figure>
<p>直接访问 <code>http://127.0.0.1:8000/static/kk02.jpg</code>就可以访问到文件夹里的图片了</p>
<p><strong>注意，在项目部署上线后，静态访问会失效</strong></p>
<h2 id="Django正则路径"><a href="#Django正则路径" class="headerlink" title="Django正则路径"></a>Django正则路径</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">urlpatterns=[</span><br><span class="line">    path(<span class="string">'index/'</span>,views.index),</span><br><span class="line">    re_path(<span class="string">r'^(?P&lt;question_id&gt;[0-9]&#123;4&#125;)/$'</span>,views.detail),</span><br><span class="line">    re_path(<span class="string">r'^(\d+)/results/$'</span>,views.results),</span><br><span class="line">    re_path(<span class="string">r'^(\d+)/vote/$'</span>,views.vote)</span><br><span class="line">]</span><br></pre></td></tr></table></figure>
<h2 id="GET获取查询字符串"><a href="#GET获取查询字符串" class="headerlink" title="GET获取查询字符串"></a>GET获取查询字符串</h2><p>GET获取的是QueryDict类型变量</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">get_query</span><span class="params">(request)</span>:</span></span><br><span class="line">    query_dict = request.GET</span><br><span class="line">    print(query_dict.get(<span class="string">'a'</span>))</span><br><span class="line">    <span class="keyword">return</span> HttpResponse(<span class="string">'response get_query'</span>)</span><br></pre></td></tr></table></figure>
<p>query_dict的值为：<br><code>&lt;QueryDict: {&#39;a&#39;: [&#39;10&#39;]}&gt;</code></p>
<p>get后，打印出的值就是10</p>
<h2 id="POST提取请求体表单数据"><a href="#POST提取请求体表单数据" class="headerlink" title="POST提取请求体表单数据"></a>POST提取请求体表单数据</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">get_form</span><span class="params">(request)</span>:</span></span><br><span class="line">    query_dict = request.POST</span><br><span class="line">    print(query_dict.get(<span class="string">'a'</span>))</span><br><span class="line">    <span class="keyword">return</span> HttpResponse(<span class="string">'response get_form'</span>)</span><br></pre></td></tr></table></figure>
<h2 id="POST提取非表单类型"><a href="#POST提取非表单类型" class="headerlink" title="POST提取非表单类型"></a>POST提取非表单类型</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> json</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">get_body_json</span><span class="params">(request)</span>:</span></span><br><span class="line">    json_str = request.body</span><br><span class="line">    json_str = json_str.decode()  <span class="comment"># python3.6 无需执行此步</span></span><br><span class="line">    req_data = json.loads(json_str)</span><br><span class="line">    print(req_data[<span class="string">'a'</span>])</span><br><span class="line">    print(req_data[<span class="string">'b'</span>])</span><br><span class="line">    <span class="keyword">return</span> HttpResponse(<span class="string">'OK'</span>)</span><br></pre></td></tr></table></figure>
<h2 id="请求头"><a href="#请求头" class="headerlink" title="请求头"></a>请求头</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">get_headers</span><span class="params">(request)</span>:</span></span><br><span class="line">    print(request.META[<span class="string">'CONTENT_TYPE'</span>])</span><br><span class="line">    <span class="keyword">return</span> HttpResponse(<span class="string">'OK'</span>)</span><br></pre></td></tr></table></figure>
<h2 id="Response"><a href="#Response" class="headerlink" title="Response"></a>Response</h2><p>基本操作</p>
<p><code>HttpResponse(content=响应体, content_type=响应体数据类型, status=状态码)</code></p>
<p>jsonResponse</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> django.http <span class="keyword">import</span> JsonResponse</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">demo_view</span><span class="params">(request)</span>:</span></span><br><span class="line">    <span class="keyword">return</span> JsonResponse(&#123;<span class="string">'city'</span>: <span class="string">'beijing'</span>, <span class="string">'subject'</span>: <span class="string">'python'</span>&#125;)</span><br></pre></td></tr></table></figure>
<h2 id="重定向"><a href="#重定向" class="headerlink" title="重定向"></a>重定向</h2><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">redirect_demo</span><span class="params">(request)</span>:</span></span><br><span class="line">    <span class="keyword">return</span> redirect(<span class="string">'/users/index/'</span>) <span class="comment"># 注意这里最前面加/代表从根路由进行重定向，否则进行拼接</span></span><br></pre></td></tr></table></figure>
<h2 id="反向解析"><a href="#反向解析" class="headerlink" title="反向解析"></a>反向解析</h2>
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2021/01/30/python求微分方程数值解/" rel="next" title="python求微分方程数值解">
                <i class="fa fa-chevron-left"></i> python求微分方程数值解
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2021/04/12/html基础/" rel="prev" title="html基础">
                html基础 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            Table of Contents
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            Overview
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">Kai</p>
              <p class="site-description motion-element" itemprop="description">这里我会放一些平常学习积累的东西，我的邮箱是hxk0912@foxmail.com</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives/">
              
                  <span class="site-state-item-count">129</span>
                  <span class="site-state-item-name">posts</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">38</span>
                  <span class="site-state-item-name">categories</span>
                </a>
              </div>
            

            

          </nav>

          

          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#WEB程序执行流程"><span class="nav-number">1.</span> <span class="nav-text">WEB程序执行流程</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#MVC设计模式"><span class="nav-number">2.</span> <span class="nav-text">MVC设计模式</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#MVT设计模式"><span class="nav-number">3.</span> <span class="nav-text">MVT设计模式</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#创建工程"><span class="nav-number">4.</span> <span class="nav-text">创建工程</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#创建子应用"><span class="nav-number">5.</span> <span class="nav-text">创建子应用</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#创建视图"><span class="nav-number">6.</span> <span class="nav-text">创建视图</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#访问静态文件"><span class="nav-number">7.</span> <span class="nav-text">访问静态文件</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Django正则路径"><span class="nav-number">8.</span> <span class="nav-text">Django正则路径</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#GET获取查询字符串"><span class="nav-number">9.</span> <span class="nav-text">GET获取查询字符串</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#POST提取请求体表单数据"><span class="nav-number">10.</span> <span class="nav-text">POST提取请求体表单数据</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#POST提取非表单类型"><span class="nav-number">11.</span> <span class="nav-text">POST提取非表单类型</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#请求头"><span class="nav-number">12.</span> <span class="nav-text">请求头</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Response"><span class="nav-number">13.</span> <span class="nav-text">Response</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#重定向"><span class="nav-number">14.</span> <span class="nav-text">重定向</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#反向解析"><span class="nav-number">15.</span> <span class="nav-text">反向解析</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Kai</span>

  
</div>


  <div class="powered-by">Powered by <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a></div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">Theme &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Muse</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  
  
    <script type="text/x-mathjax-config">
      MathJax.Hub.Config({
        tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
        }
      });
    </script>

    <script type="text/x-mathjax-config">
      MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax(), i;
        for (i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
        }
      });
    </script>
    <script type="text/javascript" src="//cdn.bootcss.com/mathjax/2.7.1/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
  


  

  

</body>
</html>
